<template>
	<view class="web_view">
		<web-view :src="src" @message="getH5Message"></web-view>
	</view>
</template>

<script>
	import api from "@/config/api.js";
	import storage from "@/utils/storage.js";
	export default {
		data() {
			return {
				src: "",
				info: {},
			};
		},
		onLoad(option) {
			this.info = JSON.parse(option.info);
			this.src = "https://health-2.westts.cn/#/" + "?query=" + option.val;
			// this.src = "http://47.108.58.157:1111/test/index.html";
		},
		onBackPress(option) {
			if (option.from === "navigateBack") {
				return false;
			}
			this.back();
			return true;
		},
		methods: {
			getH5Message(e) {
				console.log('======================')
				this.back()
			},
			back() {
				// var pages = getCurrentPages();
				// var page = pages[pages.length - 1];
				// var currentWebview = page.$getAppWebview();
				uni.showModal({
					title: "退出",
					content: "是否退出直播间？",
					success: (res) => {
						if (res.confirm) {
							uni.navigateBack({
								delta: 1
							});
							// uni.request({
							//   url: api.expert + "/expert/broadcast/studio/close",
							//   method: "POST",
							//   header: {
							//     "content-type": "application/json",
							//     accessToken: storage.getAccessToken(),
							//     refreshToken: storage.getRefreshToken(),
							//   },
							//   data: {
							//     roomId: this.info.roomId,
							//     userId: this.info.userId,
							//   },
							//   success: () => {
							//     uni.navigateBack({ delta: 1 });
							//   },
							// });
						}
					},
				});
			},
		},
	};
</script>

<style></style>
